package org.example.config;

import lombok.Builder;
import lombok.Data;

import java.io.Serializable;
import java.util.List;
import java.util.Map;

@Data
@Builder
public class MultiTableConfig implements Serializable {
    private static final long serialVersionUID = 1L;

    // Kafka 配置
    private String kafkaBootstrapServers;
    private String kafkaTopic;
    private String kafkaGroupId;
    
    // Hudi 基础配置
    private String hudiBasePath;
    private String hudiTableType;  // COW 或 MOR
    private String hudiPrecombineField;
    private String hudiRecordKeyField;
    
    // 表映射配置：key是源数据库.表名，value是目标Hudi表名
    private Map<String, TableMappingConfig> tableMappings;
    
    // Checkpoint 配置
    private String checkpointPath;
    private int checkpointInterval;  // 单位：毫秒
    private int checkpointTimeout;   // checkpoint超时时间，单位：毫秒
    private int minPauseBetweenCheckpoints;  // 两个checkpoint之间的最小间隔，单位：毫秒
    private int maxConcurrentCheckpoints;    // 同时进行的checkpoint数量
    private int tolerableCheckpointFailureNumber;  // 允许checkpoint失败的次数

    // 默认值
    public static final int DEFAULT_CHECKPOINT_TIMEOUT = 60000;
    public static final int DEFAULT_MIN_PAUSE_BETWEEN_CHECKPOINTS = 5000;
    public static final int DEFAULT_MAX_CONCURRENT_CHECKPOINTS = 1;
    public static final int DEFAULT_TOLERABLE_CHECKPOINT_FAILURE_NUMBER = 3;
    
    // 内部类，用于表映射配置
    @Data
    @Builder
    public static class TableMappingConfig implements Serializable {
        private static final long serialVersionUID = 1L;
        
        // 目标Hudi表名
        private String hudiTableName;
        
        // 分区字段
        private String hudiPartitionPathField;
        
        // 字段映射关系 (源字段名 -> 目标字段名)
        private Map<String, String> fieldMappings;
        
        // 表结构定义 (字段名 -> 字段类型)
        private Map<String, String> fieldTypes;
    }
} 